home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / InstallMaster 7.03 / Devfulldemo.exe / file0147.bin < prev    next >
Encoding:
Text File  |  1999-04-26  |  2.9 KB  |  76 lines

  1. #include <windows.h>
  2. #include "wisedll.h"
  3.  
  4. void GetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue);
  5. void SetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue);
  6.  
  7. int CALLBACK LibMain(HINSTANCE hInst, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  8. {
  9.   return(1);
  10. }
  11.  
  12. // GetCPU: Uses the new Win32 API call to get the CPU type including
  13. //         the Pentium processor. You must pass the name of the variable
  14. //         to save the name of the cpu into in the parameter field.
  15.  
  16. __declspec(dllexport) BOOL CALLBACK GetCPU(LPDLLCALLPARAMS lpDllParams)
  17. {
  18.    SYSTEM_INFO SystemInfo;
  19.    GetSystemInfo(&SystemInfo);
  20.    if (lpDllParams->lpszParam) {
  21.       switch (SystemInfo.dwProcessorType) {
  22.        case PROCESSOR_INTEL_386: SetVariable(lpDllParams,lpDllParams->lpszParam,"I386"); break;
  23.        case PROCESSOR_INTEL_486: SetVariable(lpDllParams,lpDllParams->lpszParam,"I486"); break;
  24.        case PROCESSOR_INTEL_PENTIUM: SetVariable(lpDllParams,lpDllParams->lpszParam,"PENTIUM"); break;
  25.        case PROCESSOR_MIPS_R4000: SetVariable(lpDllParams,lpDllParams->lpszParam,"R4000"); break;
  26.        case PROCESSOR_ALPHA_21064: SetVariable(lpDllParams,lpDllParams->lpszParam,"ALPHA"); break;
  27.       }
  28.    }
  29.    return FALSE;
  30. }
  31.  
  32. // GetVariable: Returns the value of a variable.
  33. //
  34. // lpDllParams  Parameter structure passed from Wise Installation
  35. // szVariable   Name of the variable (without %'s) to get value for
  36. // szValue      String that will hold the variables value
  37.  
  38. void GetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue)
  39. {
  40.    WORD i;
  41.    char szVar[32];
  42.  
  43.    *szVar = '%';
  44.    lstrcpy(&szVar[1],szVariable);
  45.    lstrcat(szVar,"%");
  46.    for (i = 0 ; (i < lpDllParams->wCurrReps) &&
  47.       (lstrcmp(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar) != 0) ; i++) ;
  48.    if (i < lpDllParams->wCurrReps) {
  49.       lstrcpy(szValue,&lpDllParams->lpszRepStr[i * lpDllParams->wRepStrWidth]);
  50.    } else *szValue = '\0';
  51. }
  52.  
  53. // SetVariable: Sets/Creates a variable.
  54. //
  55. // lpDllParams  Parameter structure passed from Wise Installation
  56. // szVariable   Name of the variable (without %'s) to set value for
  57. // szValue      String that contains the variables new value
  58.  
  59. void SetVariable(LPDLLCALLPARAMS lpDllParams,char *szVariable,char *szValue)
  60. {
  61.    WORD i;
  62.    char szVar[32];
  63.  
  64.    *szVar = '%';
  65.    lstrcpy(&szVar[1],szVariable);
  66.    lstrcat(szVar,"%");
  67.    for (i = 0 ; (i < lpDllParams->wCurrReps) &&
  68.       (lstrcmp(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar) != 0) ; i++) ;
  69.    if (i >= lpDllParams->wCurrReps) {
  70.       if (i >= lpDllParams->wMaxReplaces) return; // Too many variables
  71.       lstrcpy(&lpDllParams->lpszRepName[i * lpDllParams->wRepNameWidth],szVar);
  72.       lpDllParams->wCurrReps++;
  73.    }
  74.    lstrcpy(&lpDllParams->lpszRepStr[i * lpDllParams->wRepStrWidth],szValue);
  75. }
  76.